package edu.xkd.slice;

import edu.xkd.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.Text;

public class MainAblitySlice03 extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main_03);

        Text text_info = (Text) this.findComponentById(ResourceTable.Id_text_info);
        Button button_back_02 = (Button) this.findComponentById(ResourceTable.Id_button_back_02);

        String name = intent.getStringParam("name");
        int age = intent.getIntParam("age", 18);

        //设置值
        text_info.setText("传递过来的数据为:姓名:"+name+",年龄:"+age);
        button_back_02.setClickedListener(this::onClickListenerButtonBack02);
    }

    private void onClickListenerButtonBack02(Component component) {
        this.terminate();
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
